Skip to content

feat: add tree view component #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: release-candidate-v0.39.0
Choose a base branch
from

Conversation

AbhishekA1509
Copy link
Member

@AbhishekA1509 AbhishekA1509 commented Jun 30, 2025

Description

Adds a new TreeView component (with types, styles, and node rendering), deprecates the old CollapsibleList, refactors ActionMenu and Tooltip to share a text-truncation hook, and migrates the Security sidebar to use the new tree structure.

  • Introduce TreeView component and deprecate CollapsibleList.
  • Extract TrailingItem and integrate it into ActionMenu.
  • Update SecurityModal sidebar config to output TreeViewProps['nodes'] with dynamic counters.
  • Extract useIsTextTruncated hook and update Tooltip to consume it.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Checklist

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

Copilot

This comment was marked as outdated.

@AbhishekA1509 AbhishekA1509 changed the base branch from develop to release-candidate-v0.39.0 July 3, 2025 10:23
@AbhishekA1509 AbhishekA1509 requested a review from Copilot July 3, 2025 10:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new TreeView component (with types, styles, and node rendering), deprecates the old CollapsibleList, refactors ActionMenu and Tooltip to share a text-truncation hook, and migrates the Security sidebar to use the new tree structure.

  • Introduce TreeView component and deprecate CollapsibleList.
  • Extract TrailingItem and integrate it into ActionMenu.
  • Update SecurityModal sidebar config to output TreeViewProps['nodes'] with dynamic counters.
  • Extract useIsTextTruncated hook and update Tooltip to consume it.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Shared/Components/TreeView/TreeView.component.tsx Implementation of the new TreeView rendering, keyboard support and controlled/uncontrolled modes
src/Shared/Components/ActionMenu/ActionMenuItem.tsx Refactor to use extracted TrailingItem component
src/Shared/Components/Security/SecurityModal/config/Sidebar.ts Migrate sidebar data generation to output TreeView nodes
src/Pages/ResourceBrowser/ResourceBrowser.Types.ts Remove deprecated isExpanded property from K8SObjectBaseType
src/Common/Tooltip/UseIsTextTruncated.ts & Tooltip.tsx Extract and use text-truncation hook across tooltips
Comments suppressed due to low confidence (1)

src/Pages/ResourceBrowser/ResourceBrowser.Types.ts:40

  • Removing the isExpanded property is a breaking change; ensure dependent code and tests are updated accordingly or provide a migration path.
    name: string

? getUpdateItemsRefMapProp(node.id)
: getUpdateItemsRefMap(node.id)
}
{...node.dataAttributes}
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spreading node.dataAttributes directly may throw if it's undefined; consider using a safe fallback like {...(node.dataAttributes || {})}.

Suggested change
{...node.dataAttributes}
{...(node.dataAttributes || {})}

Copilot uses AI. Check for mistakes.

default:
return null
}
return <TrailingItem {...trailingItem} variant={type} />
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variant prop of TrailingItem expects 'neutral' | 'negative', but type (icon/text/counter/...) is passed here; update to pass a valid variant or remove it.

Copilot uses AI. Check for mistakes.

Comment on lines +169 to +183
// eslint-disable-next-line no-param-reassign
item.trailingItem = threatCount
? {
type: 'counter',
config: {
value: threatCount,
isSelected: selectedId === item.id,
},
}
: null
})
}
})

return nodes
Copy link
Preview

Copilot AI Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This mutates the input nodes array in place; consider returning a new array or mapping nodes to avoid side effects.

Suggested change
// eslint-disable-next-line no-param-reassign
item.trailingItem = threatCount
? {
type: 'counter',
config: {
value: threatCount,
isSelected: selectedId === item.id,
},
}
: null
})
}
})
return nodes
return {
...item,
trailingItem: threatCount
? {
type: 'counter',
config: {
value: threatCount,
isSelected: selectedId === item.id,
},
}
: null,
}
})
return {
...node,
items: updatedItems,
}
}
return node
})
return updatedNodes

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant